
import java.util.HashMap;
import java.util.Map;

/**
 * provides a static method for building a frequency table with the given String
 * @author baotam
 *
 */
public abstract class HuffmanEncoding {
	
    public static Map<Character, Integer> generateFrequencyTable(String text){
    	Map<Character, Integer> frequencyTable = new HashMap<Character, Integer>();
    	for(int i = 0; i < text.length(); i++) {
    		Character currentChar = (Character)text.charAt(i);
    		if(frequencyTable.get(currentChar) == null) {
    			frequencyTable.put(currentChar, 1);
    		}
    		else {
    			frequencyTable.put(currentChar, frequencyTable.get(currentChar)+1);
    		}
    	}
        return frequencyTable;
    }
    
}
